#include <linux/kobject.h>
#include <linux/sysfs.h>
#include <linux/module.h>
#include <linux/init.h>
MODULE_LICENSE("GPL");
static struct kobject *kobj;
struct kobject *kobject_create_and_add(const char *name, struct kobject *parent)
{
	        struct kobject *kobj;
	        int retval;
	        kobj = kobject_create();
	        if (!kobj)
	                return NULL;
	        retval = kobject_add(kobj, parent, "%s", name);
	        if (retval) {
			printk(KERN_WARNING "%s: kobject_add error: %d\n",
                       __FUNCTION__, retval);
	           kobject_put(kobj);
												                kobj = NULL;
														        }
							        return kobj;
}
static int __init my_init(void)
{
	    kobj = kobject_create_and_add("kobject_example", NULL);

	        return 0;
}

static void __exit my_exit(void)
{
	    if(kobj)kobject_put(kobj);
}

module_init(my_init);
module_exit(my_exit);
